home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: linkVolume.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:38 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "bf.h"
- #include "volume.h"
- #include "bitvec.h"
- #include "threadstate.h"
- #include "disk.h"
- #include "lsn.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "openlog.h"
- #include "disk_funcs.h"
- #include "msg_funcs.h"
- #include "log_intfuncs.h"
- #include "disk_globals.h"
-
-
- int
- linkVolume (
-
- register LINK *link,
- register VOLREC *volRec
- )
- {
-
- VOLINFO *volInfo;
- TRANSREC *transRec;
-
- TRPRINT(TR_CL, TR_LEVEL_1, ("linking volume:%d to link:%d",
- volRec->header->volid, link->id));
-
- /*
- * get a pointer to the first volinfo off the vol record
- */
- volInfo = (VOLINFO *) FIRST_LIST_ELEMENT( &(link->volList) );
-
- /*
- * run through the open list for this link
- */
- while (volInfo != NULL) {
-
- /*
- * check to see if the vol is the target vol
- */
- if (volInfo->volRec == volRec) {
-
- TRPRINT(TR_CL, TR_LEVEL_2, ("vol is open by link"));
-
- /*
- * just return success
- */
- return(esmNOERROR);
- }
-
- /*
- * get a pointer to the next link element
- */
- volInfo = (VOLINFO *) NEXT_LIST_ELEMENT( &(volInfo->linkList) );
- }
-
- /*
- * attempt to get a vol info structure
- */
- if ((volInfo = (VOLINFO *) listDeq( &VolInfoPool )) == NULL) {
-
- SM_ERROR(TYPE_LOG, esmNOVOLINFO);
- return(esmFAILURE);
- }
-
- /*
- * fill in the fields of the link
- */
- volInfo->volid = volRec->header->volid;
- volInfo->volRec = volRec;
- volInfo->link = link;
-
- /*
- * hang the structure off the owner link and the vol table
- */
- listEnq( &(volRec->openList), &(volInfo->volList) );
- listEnq( &(link->volList), &(volInfo->linkList) );
-
- /*
- * For each transaction on this link, add the volume to
- * the transaction's list of mounted volumes
- */
- transRec = (TRANSREC*) FIRST_LIST_ELEMENT(&(link->transList));
- while (transRec != NULL) {
-
- CHECK_TRANSREC_MAGIC(transRec);
- if (addTransVolRec(transRec, volRec) == NULL) {
- return(esmFAILURE);
- }
- transRec = (TRANSREC*) NEXT_LIST_ELEMENT(&(transRec->linkList));
- }
-
- /*
- * return success
- */
- return(esmNOERROR);
- }
-